import tensorflow as tf
#wrapper function which accepts the threshold parameter
def my_huber_loss_withthreshold(threshold) :
    def my_huber_loss(y_true, y_pred) :
        error=y_true-y_pred
        is_small_error=tf.abs(error)<=threshold
        small_error_loss=tf.square(error)/2
        big_error_loss=threshold*(tf.abs(error)-0.5*threshold)
        return tf.where(is_small_error,small_error_loss,big_error_loss)
    return my_huber_loss